//让玩家可以有两把主武器 call fn_doubleWeapon;


as_wh_player = "GroundWeaponHolder_Scripted" createVehicle [1000,1000,1000];
//as_wh_player attachTo [player, [0,0,0], "Pelvis"];
as_wh_player setVariable ["no_cleanup", true, true];
as_wh_player hideObjectGlobal true;

//已存入武器类型
as_wh_type = "";

as_wh_ing = false;

fnc_whAction = {
	if(as_wh_type == "")then{
		player setUserActionText [as_wh_action, format["<t color='#38e987'>%1</t>", localize "STR_TAG_A_10"]];
	}else{
		
		player setUserActionText [as_wh_action, format["<t color='#38e987'>%1</t><img size='1' shadow='1' image='%2'/>", localize "STR_TAG_A_10",
			gettext (configFile >> "cfgWeapons" >> as_wh_type >> "picture")]];
			
		/*player setUserActionText [as_wh_action, format["<t color='#38e987'>%1</t><t color=""#d50e0e"">[%2]</t>", localize "STR_TAG_A_10",
			getText(configFile >> "CfgWeapons" >> as_wh_type >> "displayname")]]; */	
	};
};

as_wh_action = player addAction [
	format["<t color='#38e987'>%1</t>", localize "STR_TAG_A_10"],
	{
		[] spawn{
			as_wh_ing = true;
			private _type = primaryWeapon player;
			if(as_wh_type == "")then{
				if(_type == "")then{
				}else{
					//存入主武器
					player action ["DropWeapon", as_wh_player, _type];
					Sleep 2;
					
					//检测成功
					if(primaryWeapon player != _type) then{
						as_wh_type = _type;
						
						//取出所有弹夹
						//hint str magazineCargo as_wh_player;
						{
							player addMagazine _x;
						}forEach (magazineCargo as_wh_player);
						clearMagazineCargo as_wh_player;
						
						call fnc_whAction;
					};
				};
			}else{
				if(_type == "")then{
					//取出已存入武器
					player action ["TakeWeapon", as_wh_player, as_wh_type];
					Sleep 2;
					
					//检测成功
					if(primaryWeapon player == as_wh_type) then{
						as_wh_type = "";
						call fnc_whAction;
					};
				}else{
					//存入主武器，然后取出已存入
					player action ["DropWeapon", as_wh_player, _type];
					player action ["TakeWeapon", as_wh_player, as_wh_type];
					Sleep 2;
					
					//检测成功
					if(primaryWeapon player == as_wh_type) then{
						as_wh_type = _type;
						
						//取出所有弹夹
						//hint str magazineCargo as_wh_player;
						{
							player addMagazine _x;
						}forEach (magazineCargo as_wh_player);
						clearMagazineCargo as_wh_player;
						
						call fnc_whAction;
					};
				};
			};
			Sleep 3;
			as_wh_ing = false;
		};
	},
	[],
	-999,
	false,
	true,
	"",
	"!as_wh_ing && {player == vehicle player}"
];
